{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "4f68bf86-fb3b-453a-85ae-dfa702070bd6",
   "metadata": {},
   "source": [
    "# 👋🌍 Hello, world: Submit a Qiskit job to Quantinuum\n",
    "\n",
    "In this notebook, we'll review the basics of Azure Quantum by submitting a simple *job*, or quantum program, to [Quantinuum](https://aka.ms/AQ/Quantinuum/Documentation). We will use [Qiskit](https://qiskit.org/) to express the quantum job."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ed8cda3b-cac7-4a57-8ea0-ac9cba831a36",
   "metadata": {
    "nteract": {
     "transient": {
      "deleting": false
     }
    }
   },
   "source": [
    "## Submit a simple job to Quantinuum using Azure Quantum\n",
    "Azure Quantum provides several ways to express quantum programs. In this example we are using Qiskit, but note that Q# and Cirq are also supported. All code in this example will be written in Python.\n",
    "\n",
    "Let's begin. When you see a code block, hover over it and click the triangle play-button to execute it. To avoid any compilation issues, this should be done in order from top to bottom."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4b7e2f18-b0f8-41b5-9ec2-2907f47959e2",
   "metadata": {
    "nteract": {
     "transient": {
      "deleting": false
     }
    }
   },
   "source": [
    "### 1. Connect to the Azure Quantum workspace\n",
    "\n",
    "To connect to the Azure Quantum service, construct an instance of the `AzureQuantumProvider`. Note that it's imported from `azure.quantum.qiskit`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d171c652-649f-470d-a980-d02bae9a93db",
   "metadata": {},
   "outputs": [],
   "source": [
    "from azure.quantum.qiskit import AzureQuantumProvider\n",
    "provider = AzureQuantumProvider (\n",
    "    resource_id = \"\",\n",
    "    location = \"\"\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4bd4be5e-0444-431d-a49e-ce459f07bb2d",
   "metadata": {
    "nteract": {
     "transient": {
      "deleting": false
     }
    }
   },
   "source": [
    "Let's see what providers and targets are enabled in this workspace with the following command:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "bfd720b7-df1d-4e7e-aaa9-3c6c2fbf29ab",
   "metadata": {
    "jupyter": {
     "outputs_hidden": false,
     "source_hidden": false
    },
    "nteract": {
     "transient": {
      "deleting": false
     }
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This workspace's targets:\n",
      "- ionq.qpu\n",
      "- ionq.simulator\n",
      "- quantinuum.qpu.h1-1\n",
      "- quantinuum.sim.h1-1sc\n",
      "- quantinuum.sim.h1-1e\n"
     ]
    }
   ],
   "source": [
    "from qiskit import QuantumCircuit\n",
    "from qiskit.visualization import plot_histogram\n",
    "from qiskit.tools.monitor import job_monitor\n",
    "\n",
    "print(\"This workspace's targets:\")\n",
    "for backend in provider.backends():\n",
    "    print(\"- \" + backend.name())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "61816cb6-3434-470b-89eb-13192648cfaf",
   "metadata": {
    "nteract": {
     "transient": {
      "deleting": false
     }
    }
   },
   "source": [
    "### ❕ Do you see `quantinuum.sim.h1-1sc` in your list of targets? If so, you're ready to keep going.\n",
    "\n",
    "Don't see it? You may need to add Quantinuum to your workspace to run this sample. Navigate to the **Providers** page in the portal and click **+Add** to add the Quantinuum provider. Don't worry, there's a free credits plan available.\n",
    "\n",
    "## Quantinuum: The quantum provider\n",
    "Azure Quantum partners with third-party companies to deliver solutions to quantum jobs. These company offerings are called *providers*. Each provider can offer multiple *targets* with different capabilities. See the table below for Quantinuum's H1-1 device targets.\n",
    "\n",
    "| Target name | Target ID | Number of qubits | Description|\n",
    "| --- | ---| ---|---|\n",
    "H1-1 Syntax Checker | `quantinuum.sim.h1-1sc` | 20 | Quantinuum's H1-1 Syntax Checker. This will return all zeros in place of actual or simulated results. Use this to validate quantum programs against the H1-1 compiler before submitting to hardware or emulators on Quantinuum's platform. Free of cost. |\n",
    "H2-1 Syntax Checker | `quantinuum.sim.h2-1sc` | 32 | Quantinuum's H2-1 Syntax Checker. This will return all zeros in place of actual or simulated results. Use this to validate quantum programs against the H2-1 compiler before submitting to hardware or emulators on Quantinuum's platform. Free of cost.  |\n",
    "H1-1 Emulator | `quantinuum.sim.h1-1e` | 20 | Quantinuum's H1-1 Emulator. Uses a realistic physical model and noise model of H1-1. |\n",
    "H2-1 Emulator | `quantinuum.sim.h2-1e` | 32 | Quantinuum's H2-1 Emulator. Uses a realistic physical model and noise model of H2-1. |\n",
    "H1-1 | `quantinuum.qpu.h1-1` | 20 | Quantinuum's H1-1 trapped ion device. |\n",
    "H2-1 | `quantinuum.qpu.h2-1` | 32 | Quantinuum's H2-1 trapped ion device. |\n",
    "\n",
    "For this example, we will use `quantinuum.sim.h1-1sc` to avoid any costs or credit usage. If you wish to emulate or run the actual circuit, you may replace all instances of `quantinuum.sim.h1-1sc` in subsequent code cells with one of the other values in the table above, but please note any costs incurred. To learn more about Quantinuum's targets, check out our [documentation](https://aka.ms/AQ/Quantinuum/Documentation)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "563fa196-7efd-47a2-a3dd-e6f4f6d0031b",
   "metadata": {},
   "source": [
    "### 2. Build the quantum program\n",
    "\n",
    "Let's create a simple Qiskit circuit to run."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9deacc51-c2ea-43a3-a474-c4ff62798609",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"word-wrap: normal;white-space: pre;background: #fff0;line-height: 1.1;font-family: &quot;Courier New&quot;,Courier,monospace\">     ┌───┐┌─┐\n",
       "  q: ┤ H ├┤M├\n",
       "     └───┘└╥┘\n",
       "c: 1/══════╩═\n",
       "           0 </pre>"
      ],
      "text/plain": [
       "     ┌───┐┌─┐\n",
       "  q: ┤ H ├┤M├\n",
       "     └───┘└╥┘\n",
       "c: 1/══════╩═\n",
       "           0 "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Create a quantum circuit acting on a single qubit\n",
    "circuit = QuantumCircuit(1,1)\n",
    "circuit.name = \"Single qubit random\"\n",
    "circuit.h(0)\n",
    "circuit.measure(0, 0)\n",
    "\n",
    "# Print out the circuit\n",
    "circuit.draw()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a9c43dfa-8fd0-435b-90a8-496697d48d33",
   "metadata": {
    "nteract": {
     "transient": {
      "deleting": false
     }
    }
   },
   "source": [
    "The circuit you built is a simple quantum random bit generator. With Quantinuum's Syntax Checker, we will be able to confirm that the circuit is able to be run on the Quantinuum H1-1 emulator and hardware."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "71ab1f66-2a22-4bed-a5cb-6a5f431456ea",
   "metadata": {},
   "source": [
    "### 3. Submit the quantum program to Quantinuum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "55072a59-3df1-4eb6-9096-35fe4f2b4fc0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Job id: cc4ff1e7-0213-11ed-bcce-f42679f0b639\n"
     ]
    }
   ],
   "source": [
    "# Create an object that represents Quantinuum's Syntax Checker target, \"quantinuum.sim.h1-1sc\".\n",
    "#   Note that any target you have enabled in this workspace can\n",
    "#   be used here. Azure Quantum makes it extremely easy to submit\n",
    "#   the same quantum program to different providers. \n",
    "quantinuum_api_val_backend = provider.get_backend(\"quantinuum.sim.h1-1sc\")\n",
    "\n",
    "# Using the Quantinuum target, call \"run\" to submit the job. We'll\n",
    "# use a count of 100 (simulated runs).\n",
    "job = quantinuum_api_val_backend.run(circuit, count=100)\n",
    "print(\"Job id:\", job.id())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "68845f26-dff9-4c60-9478-895ef346231f",
   "metadata": {
    "nteract": {
     "transient": {
      "deleting": false
     }
    }
   },
   "source": [
    "The job ID can be used to retrieve the results later using the [get_details function](https://docs.microsoft.com/azure/quantum/optimization-job-reference#jobdetails) or by viewing it under the **Job management** section of the portal."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7d1e3a59-9898-41dd-93ef-2a204fbb49e8",
   "metadata": {
    "nteract": {
     "transient": {
      "deleting": false
     }
    }
   },
   "source": [
    "### 4. Obtain the job results\n",
    "You can monitor the job status with Qiskit's `job_monitor` function.\n",
    "\n",
    "This may take a minute or so ⏳. Your job will be packaged and sent to Quantinuum, where it will wait its turn to be run. You'll see your job go through these stages: \"job is queued\" &rarr; \"job is actively running\" &rarr; \"job has successfully run.\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "a88e4367-23a8-434b-8859-4d7ed328e529",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\r\n",
      "Job Status: job has successfully run\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAc0AAAFTCAYAAABbKVcuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAhzUlEQVR4nO3df7jWdZ3n8edbGBEDCnD4eTAgkAISo2N4GgLrinWlyezHpG3FuE06Wmnm1ezUbtnY9sNtGscm12lk9kqx2bJsp7byB24FhOJhDkwU0Cgb4ALyQwEDEo9C7/3je2On0/nxveVw7nNuno/rui/u+/P9fD/3+3sdDi++vz7fyEwkSVL3Tql1AZIk9ReGpiRJJRmakiSVZGhKklSSoSlJUkmGpiRJJRmakqoSEcsi4v21rkOqBUNT6uciYmtEHI6IQxGxKyJuj4ghvfTdl0XEyt74LqkvMDSl+vDmzBwCnAO8Cvh4bcuR6pOhKdWRzNwF3E8RnkTEeRHxUEQ8FRHrIuL8Y30re4mbI+JgRGyJiHdX2v8qIr7Wpt/EiMiIGNj2uyLiFcBXgKbKXu5TJ3r7pFozNKU6EhENwIXA/42I8cAPgM8AI4CPAt+OiD+MiBcBfwdcmJlDgdcCP63muzLzF8CVwKrMHJKZL+mxDZH6KENTqg/fiYiDwDZgD/Ap4D3APZl5T2b+JjMfAFqAhZ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S8BFgAzKOYnH0ncFtmHqphqXXFw7OS1A+1mchgOvCKiJiVmeuAbwHfOvaYsNpVWJ/c05SkfioiXklxxewo4JfAV4HlwE8z87la1lavDE1J6sciYhjQBHwImEBxJe3PgX8FfpyZj9WwvLpjaEpSnYiIscDFwJ9QTGpwXWZ+s6ZF1RlDU5LqTGUe2mnA9sw8WOt66omhKUlSSd6nKUlSSYamJEklGZqSJJVkaEqSVJKhKUlSSYamJEkl/X+qevHb0x5LIwAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 504x360 with 1 Axes>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "job_monitor(job)\n",
    "\n",
    "result = job.result()\n",
    "\n",
    "# The result object is native to the Qiskit package, so we can use Qiskit's tools to print the result as a histogram.\n",
    "# For the syntax check, we expect to see all zeroes.\n",
    "plot_histogram(result.get_counts(circuit), title=\"Result\", number_to_keep=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ac95a368-fe1f-42fe-bb21-11f11e63d177",
   "metadata": {
    "nteract": {
     "transient": {
      "deleting": false
     }
    }
   },
   "source": [
    "**See the histogram above? Congratulations, you've submitted a job with Azure Quantum! 👏**\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3b187952",
   "metadata": {},
   "source": [
    "### 5. Estimate costs\n",
    "\n",
    "To estimate the costs of running this program on a simulator or hardware, you can use the `backend.estimate_cost` method."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "4bfda759",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Estimated cost: 5.12 HQC\n"
     ]
    }
   ],
   "source": [
    "backend = provider.get_backend(\"quantinuum.qpu.h1-1\")\n",
    "cost = backend.estimate_cost(circuit, shots=100)\n",
    "print(f\"Estimated cost: {cost.estimated_total} {cost.currency_code}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ca314d37-ac46-4a0c-89dc-3cb063eb03b8",
   "metadata": {
    "nteract": {
     "transient": {
      "deleting": false
     }
    }
   },
   "source": [
    "### 6. Next steps\n",
    "Next, you can try running a program on Quantinuum's H1-1 emulation and hardware targets. Just replace `quantinuum.sim.h1-1sc` with `quantinuum.sim.h1-1e` or `quantinuum.qpu.h1-1`. Or try another sample by navigating back to the sample gallery. The same \"hello world\" sample can be run with different quantum providers by choosing another option in the gallery card drop-down menu. Don't worry - your work here is automatically saved.\n",
    "\n",
    "To learn more about submitting Qiskit circuits to Azure Quantum, review [this documentation](https://docs.microsoft.com/azure/quantum/quickstart-microsoft-qiskit?pivots=platform-quantinuum).\n",
    "\n",
    "To learn more about job pricing, review the [Azure Quantum documentation on job costs](https://docs.microsoft.com/azure/quantum/azure-quantum-job-costs)."
   ]
  }
 ],
 "metadata": {
  "kernel_info": {
   "name": "python3"
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  },
  "nteract": {
   "version": "nteract-front-end@1.0.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
